﻿namespace Collections;

public class HashSetItems
{
    public void MyHashSet()
    {
        HashSet<string> messages = new HashSet<string>()
        {
            "Morning", "How are you", "Have a good day"
        };

        HashSet<string> emp1 = new HashSet<string>()
        {
            "Anna", "Jack", "Tom"
        };

        HashSet<string> emp2 = new HashSet<string>()
        {
            "Jerry", "Jack", "Tom", "Scott"
        };

        // Union
        emp1.UnionWith(emp2);
        foreach (var item in emp1)
        {
            Console.WriteLine(item);
        }

        // Add 
        messages.Add("Good luck");

        // Remove
        messages.Remove("Have a good day");

        // Remove
        messages.RemoveWhere(m => m.EndsWith("day"));

        // Count
        Console.WriteLine("Count:" + messages.Count);

        // Search
        bool b = messages.Contains("Morning");
        Console.WriteLine(b);
    }
}